package com.lsqingfeng.springboot.controller;

import com.lsqingfeng.springboot.vo.User;
import org.springframework.web.bind.annotation.*;

/**
 * @className: SecondController
 * @description:
 * @author: sh.Liu
 * @date: 2022-01-12 11:25
 */
@RestController
public class SecondController {

    @PostMapping("second")
    public User second(){
        User u = new User("张胜男", 30,"女");
        return u;
    }

    @GetMapping("third")
    public String third(String name, Integer age){
        System.out.println(name);
        System.out.println(age);
        return "success";
    }

    @GetMapping("getParam")
    public User getParam(User user){
        System.out.println(user);
        return user;
    }


    @PostMapping("postForm")
    public User postForm(String name, Integer age){
        User u = new User(name, age, null);
        return u;
    }

    @PostMapping("postForm2")
    public User postForm2(User user){
        return user;
    }

    @PostMapping("postJson")
    public User postJson(@RequestBody User user){
        return user;
    }


    @PostMapping("postWWWForm")
    public User postWWWForm(String name, @RequestParam Integer  age){
        return new User(name, age, null);
    }

    @PostMapping("postWWWForm2")
    public User postWWWForm2(User user){
        return user;
    }

    @GetMapping("/login")
    public String login(){
        return "success";
    }
}
